import { Button } from "antd";
import React from "react";
import { connect } from "./../../source/react-redux/index";
import { bindActionCreators } from "./../../source/redux/index";
let testAction = {
  add: (value) => {
    return { type: "SET_NUMBER", payload: value };
  },
};
class Name extends React.PureComponent {
  constructor(props) {
    super(props);
    this.state = {};
  }
  componentDidMount() {
    let { dispatch } = this.props;
    this.newAction = bindActionCreators(testAction, dispatch);
  }
  add = () => {
    console.log("newActoin:", this.newAction);
    const { add } = this.newAction;
    add(1500);
  };
  render() {
    const { name, number } = this.props;
    return (
      <div>
        test
        <span style={{ marginLeft: "20px" }}>test数字：{number}</span>
        <Button onClick={this.add} type="primary">
          加
        </Button>
      </div>
    );
  }
}
const mapStateToProps = (state) => {
  return {
    name: state.name.name,
    number: state.age.number,
  };
};
const mapDispatchToProps = (dispatch) => {
  return {
    dispatch,
  };
};
export default connect(mapStateToProps, mapDispatchToProps)(Name);
